<?php
$start  = microtime(true);
$mysqli = new mysqli("localhost", "root", "123456", "test");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* create a prepared statement */
$stmt =  $mysqli->stmt_init();

if ($stmt->prepare("SELECT id, username FROM test2"))
{
    $stmt->execute();
    $stmt->bind_result($id, $name);

    $data = array();
    while ($stmt->fetch())
    {
        $data[] = array('id' => $id, 'username' => $name);
    }

    echo microtime(true) - $start. ' seconds <br />';
    $stmt->free_result();
    $stmt->reset();

    /* close statement */
    $stmt->close();
}

/* close connection */
$mysqli->close();
?>